package czx.util;

import java.util.HashMap;
import java.util.Map;

/**
 * 自定义一个类用于Hql查询
 * 
 * @author 陈正兴
 * 
 */
public class HqlExp implements java.io.Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public HqlExp() {
	}

	public HqlExp(String hql) {
		this.hql = hql;
	}

	public HqlExp(String hql, String countHql) {
		this.hql = hql;
		this.countHql = countHql;
	}

	private String hql = "";
	private String countHql = "";
	private int pageIndex = 0;
	private int pageSize = 0;
	private Map<String, Object> params = new HashMap<String, Object>();

	public String getHql() {
		return hql;
	}

	public void setHql(String hql) {
		this.hql = hql;
	}

	public String getCountHql() {
		return countHql;
	}

	public void setCountHql(String countHql) {
		this.countHql = countHql;
	}

	/**
	 * 页数从0开始
	 * 
	 * @return 第几页
	 */
	public int getPageIndex() {
		return pageIndex;
	}

	/**
	 * 页数从0开始
	 * 
	 * @param pageIndex
	 */
	public void setPageIndex(int pageIndex) {
		this.pageIndex = pageIndex;
	}

	public int getFirstResult() {
		return pageIndex * pageSize;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public Map<String, Object> getParams() {
		return params;
	}

	public void AddParam(String paramName, Object value) {
		params.put(paramName, value);
	}

	public void ClearParams() {
		this.params.clear();
	}
}
